//
//  RecordingView.swift
//  APIEndPoint
//
//  Created by Alfred on 2021/2/7.
//

import SwiftUI

struct RecordingView: View {
    @Environment(\.managedObjectContext) var viewContext
    @FetchRequest(entity: EPdata.entity(), sortDescriptors: [NSSortDescriptor(key: "timeInterval", ascending: false)]) var records: FetchedResults<EPdata>
    
    var body: some View {
            List {
                ForEach(records) { rcd in
                    NavigationLink(destination: RecordingDetailView(timeStamp: rcd.wrappedTimeInterval, jsonData: rcd.wrappedJSONData)) {
                        Text(rcd.wrappedTimeInterval)
                    }
                }
            }
            .navigationBarTitle(Text("记录列表"), displayMode: .automatic)
        
    }
}

struct RecordingView_Previews: PreviewProvider {
    static var previews: some View {
        RecordingView()
    }
}
